package xio.ccf_201503;
/*
 * ccf 201503-2 数字排序 100分
 */
import java.util.PriorityQueue;
import java.util.Scanner;

public class NumberOrder {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] src = new int[1001];
		for (int i = 0; i < n; i++) {
			int num = sc.nextInt();
			src[num]++;
		}
		
		PriorityQueue<Pair> queue = new PriorityQueue<>();
		for (int i = 0; i < src.length; i++) {
			if (src[i] >0) {
				queue.add(new Pair(i, src[i]));
			}
		}
		
		while (!queue.isEmpty()) {
			System.out.println(queue.poll().toString());
		}
	
		
 	}
	
	static class Pair implements Comparable<Pair>{
		int num;
		int times;
		
		public Pair(int num, int times) {
			this.num = num;
			this.times = times;
		}
		
		@Override
		public String toString() {
		
			return num+" "+times;
		}

		@Override
		public int compareTo(Pair o) {
			if (this.times < o.times) {
				return 1;
			}else if (this.times > o.times) {
				return -1;
			}else {
				if (this.num > o.num) {
					return 1;
				}else if (this.num < o.num) {
					return -1;
				}else {
					return 0;
				}
			}
		}
		
	}
}
